package com.helloUIBinder.server;

import com.helloUIBinder.model.BlogPost;
import com.helloUIBinder.model.Comment;
import com.helloUIBinder.service.BlogPostManager;
import com.helloUIBinder.service.CommentManager;
import com.helloUIBinder.service.SiteUserManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import java.util.List;

@Component
@Path("/commentWebService")
public class CommentWebService {

    @Autowired
    CommentManager commentManager;

    @GET
    @Path("/id/{param}")
    @Produces("application/json")
    @Transactional
    public Comment getCommentById(@PathParam("param") String id) {
        return commentManager.findCommentById(Integer.parseInt(id));

    }

    @GET
    @Path("/all")
    @Produces("application/json")
    @Transactional
    public List<Comment> getAllComments() {
        return commentManager.getAllComments();
    }
}
